The words injective and surjective are explained and defined here. Very important: The definitions of injective and surjective depend almost completely on the choice of domain and codomain. Unless we specify the domain and codomain, it is nearly impossible to discuss this topic.
An injective function $f\,:\,A\rightarrow B$ means that every element of $A$ matches uniquely to an element of $B$. Of course, to be a function, there is no “one-to-many” match. That means $f\,:\,\mathbb{R\rightarrow\mathbb{R}\qquad}f(x)=x^{2}+y^{2}-1$ is not a function. An injective function also disallows many-to-one. So, for example, the sine function is not injective in $\mathbb{R}$, but is injective on the domain $[-1/2,1/2]$. But, the codomain can be larger than the image. That is, there can be elements in $B$ with no map from $A$. Since injective functions uniquely map $A$ to $B$, they are reversible, given an image element of $B$ we can find the input element from $A$. Functions that only increase or only decrease are injective.
Formally: A function $f\,:\,A\rightarrow B$ is injective if for $f(a)=f(b)\Rightarrow a=b$. And too the contrapositive: $f(a)\ne f(b)\Rightarrow a\ne b$. In English we might say, if $f(a)$ is equal to $f(b)$ then $a$ must be equal to $b$.
A surjective function is one where the image and the codomain are the same. That is, every $B$ is paired with at least some $A$ (it could be more than one). No $B$ is omitted. You may use the word “onto” as a synonym for surjective. Any proper function becomes surjective if its codomain is restricted to its image. Example $f\;:\;\mathbb{R}\rightarrow\mathbb{R}\qquad x\mapsto x^{3}$ is surjective because, the domain and codomain are restricted to the real numbers and every cubic polynomial with real coefficients has at least one real root.
To determine if a function is surjective, we must identify the codomain. The codomain set (set B) is part of the surjective definition.
Formally: A function $f\,:\,A\rightarrow B$ is surjective if for all $b\in B$ there exists an $a\in A$ such that $f(a)=b$.
The sine function $y=sin(x)$ is surjective for the codomain $-1 < y < 1$ but it is not surjective for a codomain greater than $1$.
A bijective function is one that is both injective and surjective at once.
Example: Define five functions that are injective, but not surjective. Explain each one.
Answer: The definitions of injective and surjective depend almost completely on the choice of domain and codomain.
$f\,:\,\mathbb{R\rightarrow C}\quad f(x)=x^{3}$. The codomain of complex numbers includes both reals and imaginaries. If $x$ is selected from the set $\mathbb{R}$ then $x^{3}$ will always return an image that is in $\mathbb{R}$. However, there are many elements in $\mathbb{C}$ that are not mapped. Therefore, $f$ is injective, but not surjective.
$f\,:\,\mathbb{R}_{>0}\rightarrow\mathbb{R}\quad f(x)=e^{x}$ The function maps positive real $x$ into all $\mathbb{R}$. It is injective because every element of $\mathbb{R}_{>0}$ matches uniquely to an element of $\mathbb{R}$. It is not surjective because the image and codomain are not the same.
$f\,:\,\mathbb{N\rightarrow R}\quad f(x)=x^{2}$. All of the natural numbers have a unique image in $\mathbb{R}$ so it is injective. However the negative real numbers are not mapped, so it is not surjective.
$f\,:\,\mathbb{N}\rightarrow\mathbb{N}\quad f(x):\,|x|>3$. Here we select natural numbers from the domain, but the image excludes the values $\left\{ 1,2,3\right\}$ , consequently, it is injective, but not surjective.
$f\,:\,\forall x\in\mathbb{R}|\left\{ -\pi/2 < x < \pi/2\right\} \rightarrow\mathbb{R}\quad f(x)=tan(x)$. The domain includes real numbers between $-\pi/2$ and $\pi/2$ where $tan(x)$ is defined, but the codomain includes all real numbers. Consequently, the domain will map uniquely into the codomain, but there are codomain elements which are excluded. Thus the function is injective, but not surjective.
Example: Define five functions that are surjective, but not injective. Explain each one.
Answer: The definitions of injective and surjective depend almost completely on the choice of domain and codomain. A surjective function must include all elements of the codomain. A function is “not injective” if it is many-to-one.
$f\,:\,\mathbb{Z}\rightarrow\left\{ 0,1,2,3,4,5,6\right\} \quad f(x)=x\,mod\,7$. The image and the codomain match. That is, all elements of the codomain are paired. That means that the function is surjective. However, because it is a many-to-one relation, it is not injective.
$f\,:\,\mathbb{R}\rightarrow\left\{ -1\le x\le1\right\} \quad f(x)=sin(x)$. The image and codomain match. $\forall x\;\left\{ -1\le x\le1\right\}$ . However, because it is a many-to-one relation, it is not injective. For example, $\sin(\pi/4)=\sin(9\pi/4)=\sqrt{2}/2$. Many values in $\mathbb{R}$ map to the same value in the codomain.
$f\,:\,\mathbb{C}\rightarrow\mathbb{C}\quad f(x)=x^{2}$. Since every complex number has a square root, and every complex number has a square, it must be that the image and codomain match, thus the function is surjective. However, since any complex number has two square roots, it must be that we have many-to-one relation, which is not injective.
$\delta\,:\,\mathbb{Z}\rightarrow\left\{ 0,1\right\} \quad\delta_{x_{1},x_{2}}=\left\{ \begin{array}{c}
0\;x_{1}\ne x_{2}\\
1\;x_{1}=x_{2}
\end{array}\right\}$ . Since the image matches the codomain, the function is surjective. Since there is also a many-to-one relation, the function is not injective.
$f\,:\,\left\{ 0,1,2,3\right\} \rightarrow\left\{ -3,-2,-1,0,1,2,3\right\} \quad f(x_{1},x_{2})=x_{2}-x_{1}$. All possible choices of $x_{1}$and $x_{2}$ result in an image that in in the codomain, so the function is injective. Some choices, map to the same image in the codomain (many-to-one), so the function is not injective.